<template>
	<web-view src="/hybrid/html/evidence-detail/index.html" :update-title="false"></web-view>
</template>

<script>
	import {
		queryTraceDetail,
		queryGpsDatetime,
	} from '@/common/api/req.js';
	import {
		VehEvidenceTrackList
	} from "@/common/api/monitor.js";
	import {
		dateFormat
	} from "@/common/util.js";
	import {
		setTimeout
	} from 'timers';
	export default {
		data() {
			return {
				resData: {},
				echartList: [],
				trajectory: [],
			}
		},
		onLoad(params) {
			// console.log(params);
			uni.setNavigationBarTitle({
				title: params.indicatorItem + '详情'
			})
			// 测试数据
			// Object.assign(params, {
			// 	infractRecordId: "1647558983832526848",
			// 	itemCode: "ybcs"
			// })
			queryTraceDetail(params)
				.then((res) => {
					Object.assign(this.resData, (res?.data?.data || {}));
					// echart数据接口
					return queryGpsDatetime({
						infractRecordId: params.infractRecordId,
					}).catch((err) => {
						console.log(err);
					});
				})
				.then((res) => {
					this.echartList = (res && res.data && res.data.data || []);
					// 轨迹数据入参
					const data = {
						vehCode: this.resData.vehCode,
						vehColor: this.resData.vehColor,
						stDate: this.resData.stDate,
						infractRecordId: params.infractRecordId,
					};
					// 轨迹数据接口
					return VehEvidenceTrackList(data).catch((err) => {
						console.log(err);
					});
				})
				.then((res) => {
					this.trajectory = (res && res.data && res.data.data || []);
					const data = {
						trajectory: this.trajectory,
						echartList: this.echartList,
						resData: this.resData,
						occurAddr: params.occurAddr,
						itemCode: params.itemCode,
					};
					console.log(data);
					const webview = this.$mp.page.$getAppWebview().children()[0];
					setTimeout(() => {
						webview.evalJS("receiveData('" + JSON.stringify(data) + "')");
					}, 300)
				})
				.catch((err) => {
					console.log(err);
				});
		}
	}
</script>

<style>

</style>